﻿namespace HRM.CORE
{

    using APP.HELPER.Data.Helper;
    using Extra.ERP;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;

    public class HRM_PROCESS_RATE
    {
        private DateTime m_Date;
        private string m_Description;
        private string m_EmployeeCode;
        private bool m_IsDiscipline;
        private bool m_IsRecidivism;
        private double m_Minus;
        private double m_MyPlus;
        private string m_MyRate;
        private double m_OwnerPlus;
        private string m_OwnerRate;
        private Guid m_RateID;
        private string m_Violation;

        public HRM_PROCESS_RATE()
        {
            this.m_RateID = Guid.Empty;
            this.m_EmployeeCode = "";
            this.m_Date = DateTime.Now;
            this.m_Violation = "";
            this.m_IsRecidivism = true;
            this.m_IsDiscipline = false;
            this.m_Minus = 0.0;
            this.m_MyPlus = 0.0;
            this.m_MyRate = "";
            this.m_OwnerPlus = 0.0;
            this.m_OwnerRate = "";
            this.m_Description = "";
        }

        public HRM_PROCESS_RATE(Guid RateID, string EmployeeCode, DateTime Date, string Violation, bool IsRecidivism, bool IsDiscipline, double Minus, double MyPlus, string MyRate, double OwnerPlus, string OwnerRate, string Description)
        {
            this.m_RateID = RateID;
            this.m_EmployeeCode = EmployeeCode;
            this.m_Date = Date;
            this.m_Violation = Violation;
            this.m_IsRecidivism = IsRecidivism;
            this.m_IsDiscipline = IsDiscipline;
            this.m_Minus = Minus;
            this.m_MyPlus = MyPlus;
            this.m_MyRate = MyRate;
            this.m_OwnerPlus = OwnerPlus;
            this.m_OwnerRate = OwnerRate;
            this.m_Description = Description;
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@RateID" };
            object[] myValues = new object[] { this.m_RateID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_RATE_Delete", myParams, myValues);
        }

        public string Delete(Guid RateID)
        {
            string[] myParams = new string[] { "@RateID" };
            object[] myValues = new object[] { RateID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_RATE_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, Guid RateID)
        {
            string[] myParams = new string[] { "@RateID" };
            object[] myValues = new object[] { RateID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_RATE_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, Guid RateID)
        {
            string[] myParams = new string[] { "@RateID" };
            object[] myValues = new object[] { RateID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_RATE_Delete", myParams, myValues);
        }

        public string DeleteByMonth(string EmployeeCode, int Month, int Year)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@Month", "@Year" };
            object[] myValues = new object[] { EmployeeCode, Month, Year };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_RATE_DeleteByMonth", myParams, myValues);
        }

        public bool Exist(Guid RateID)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@RateID" };
            object[] myValues = new object[] { RateID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_PROCESS_RATE_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(Guid RateID)
        {
            string str = "";
            string[] myParams = new string[] { "@RateID" };
            object[] myValues = new object[] { RateID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_PROCESS_RATE_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_RateID = reader.GetGuid(reader.GetOrdinal("RateID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_Violation = Convert.ToString(reader["Violation"]);
                    this.m_IsRecidivism = Convert.ToBoolean(reader["IsRecidivism"]);
                    this.m_IsDiscipline = Convert.ToBoolean(reader["IsDiscipline"]);
                    this.m_Minus = Convert.ToDouble(reader["Minus"]);
                    this.m_MyPlus = Convert.ToDouble(reader["MyPlus"]);
                    this.m_MyRate = Convert.ToString(reader["MyRate"]);
                    this.m_OwnerPlus = Convert.ToDouble(reader["OwnerPlus"]);
                    this.m_OwnerRate = Convert.ToString(reader["OwnerRate"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, Guid RateID)
        {
            string str = "";
            string[] myParams = new string[] { "@RateID" };
            object[] myValues = new object[] { RateID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "HRM_PROCESS_RATE_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_RateID = reader.GetGuid(reader.GetOrdinal("RateID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_Violation = Convert.ToString(reader["Violation"]);
                    this.m_IsRecidivism = Convert.ToBoolean(reader["IsRecidivism"]);
                    this.m_IsDiscipline = Convert.ToBoolean(reader["IsDiscipline"]);
                    this.m_Minus = Convert.ToDouble(reader["Minus"]);
                    this.m_MyPlus = Convert.ToDouble(reader["MyPlus"]);
                    this.m_MyRate = Convert.ToString(reader["MyRate"]);
                    this.m_OwnerPlus = Convert.ToDouble(reader["OwnerPlus"]);
                    this.m_OwnerRate = Convert.ToString(reader["OwnerRate"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, Guid RateID)
        {
            string str = "";
            string[] myParams = new string[] { "@RateID" };
            object[] myValues = new object[] { RateID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "HRM_PROCESS_RATE_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_RateID = reader.GetGuid(reader.GetOrdinal("RateID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_Violation = Convert.ToString(reader["Violation"]);
                    this.m_IsRecidivism = Convert.ToBoolean(reader["IsRecidivism"]);
                    this.m_IsDiscipline = Convert.ToBoolean(reader["IsDiscipline"]);
                    this.m_Minus = Convert.ToDouble(reader["Minus"]);
                    this.m_MyPlus = Convert.ToDouble(reader["MyPlus"]);
                    this.m_MyRate = Convert.ToString(reader["MyRate"]);
                    this.m_OwnerPlus = Convert.ToDouble(reader["OwnerPlus"]);
                    this.m_OwnerRate = Convert.ToString(reader["OwnerRate"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetAllList()
        {
            int level = MyLogin.Level;
            string code = MyLogin.Code;
            string[] myParams = new string[] { "@Level", "@Code" };
            object[] myValues = new object[] { level, code };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_RATE_GetAllList", myParams, myValues);
        }

        public DataTable GetAllListByDays(DateTime BeginDate, DateTime EndDate)
        {
            int level = MyLogin.Level;
            string code = MyLogin.Code;
            string[] myParams = new string[] { "@Level", "@Code", "@BeginDate", "@EndDate" };
            object[] myValues = new object[] { level, code, BeginDate, EndDate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_RATE_GetAllListByDays", myParams, myValues);
        }

        public DataTable GetList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_RATE_GetList");
        }

        public DataTable GetList(Guid RateID)
        {
            string[] myParams = new string[] { "@RateID" };
            object[] myValues = new object[] { RateID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_RATE_Get", myParams, myValues);
        }

        public DataTable GetListByDays(string EmployeeCode, DateTime BeginDate, DateTime EndDate)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@BeginDate", "@EndDate" };
            object[] myValues = new object[] { EmployeeCode, BeginDate, EndDate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_RATE_GetListByDays", myParams, myValues);
        }

        public DataTable GetListByEmployee(string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_RATE_GetListByEmployee", myParams, myValues);
        }

        public DataTable GetListByMonth(string EmployeeCode, int Month, int Year)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@Month", "@Year" };
            object[] myValues = new object[] { EmployeeCode, Month, Year };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_RATE_GetListByMonth", myParams, myValues);
        }

        public string Insert()
        {
            string[] myParams = new string[] { "@RateID", "@EmployeeCode", "@Date", "@Violation", "@IsRecidivism", "@IsDiscipline", "@Minus", "@MyPlus", "@MyRate", "@OwnerPlus", "@OwnerRate", "@Description" };
            object[] myValues = new object[] { this.m_RateID, this.m_EmployeeCode, this.m_Date, this.m_Violation, this.m_IsRecidivism, this.m_IsDiscipline, this.m_Minus, this.m_MyPlus, this.m_MyRate, this.m_OwnerPlus, this.m_OwnerRate, this.m_Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_RATE_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@RateID", "@EmployeeCode", "@Date", "@Violation", "@IsRecidivism", "@IsDiscipline", "@Minus", "@MyPlus", "@MyRate", "@OwnerPlus", "@OwnerRate", "@Description" };
            object[] myValues = new object[] { this.m_RateID, this.m_EmployeeCode, this.m_Date, this.m_Violation, this.m_IsRecidivism, this.m_IsDiscipline, this.m_Minus, this.m_MyPlus, this.m_MyRate, this.m_OwnerPlus, this.m_OwnerRate, this.m_Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_RATE_Insert", myParams, myValues);
        }

        public string Insert(Guid RateID, string EmployeeCode, DateTime Date, string Violation, bool IsRecidivism, bool IsDiscipline, double Minus, double MyPlus, string MyRate, double OwnerPlus, string OwnerRate, string Description)
        {
            string[] myParams = new string[] { "@RateID", "@EmployeeCode", "@Date", "@Violation", "@IsRecidivism", "@IsDiscipline", "@Minus", "@MyPlus", "@MyRate", "@OwnerPlus", "@OwnerRate", "@Description" };
            object[] myValues = new object[] { RateID, EmployeeCode, Date, Violation, IsRecidivism, IsDiscipline, Minus, MyPlus, MyRate, OwnerPlus, OwnerRate, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_RATE_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, Guid RateID, string EmployeeCode, DateTime Date, string Violation, bool IsRecidivism, bool IsDiscipline, double Minus, double MyPlus, string MyRate, double OwnerPlus, string OwnerRate, string Description)
        {
            string[] myParams = new string[] { "@RateID", "@EmployeeCode", "@Date", "@Violation", "@IsRecidivism", "@IsDiscipline", "@Minus", "@MyPlus", "@MyRate", "@OwnerPlus", "@OwnerRate", "@Description" };
            object[] myValues = new object[] { RateID, EmployeeCode, Date, Violation, IsRecidivism, IsDiscipline, Minus, MyPlus, MyRate, OwnerPlus, OwnerRate, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_RATE_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, Guid RateID, string EmployeeCode, DateTime Date, string Violation, bool IsRecidivism, bool IsDiscipline, double Minus, double MyPlus, string MyRate, double OwnerPlus, string OwnerRate, string Description)
        {
            string[] myParams = new string[] { "@RateID", "@EmployeeCode", "@Date", "@Violation", "@IsRecidivism", "@IsDiscipline", "@Minus", "@MyPlus", "@MyRate", "@OwnerPlus", "@OwnerRate", "@Description" };
            object[] myValues = new object[] { RateID, EmployeeCode, Date, Violation, IsRecidivism, IsDiscipline, Minus, MyPlus, MyRate, OwnerPlus, OwnerRate, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_RATE_Insert", myParams, myValues);
        }

        public string NewID()
        {
            return SqlHelper.GenCode("HRM_PROCESS_RATE", "JobCode", "CV");
        }

        public DataTable ReportRate1(int Level, string Code, int Month, int Year)
        {
            string[] myParams = new string[] { "Level", "Code", "@Month", "@Year" };
            object[] myValues = new object[] { Level, Code, Month, Year };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_RATE_ReportRate1", myParams, myValues);
        }

        public DataTable ReportRate2(int Level, string Code, int Month, int Year)
        {
            string[] myParams = new string[] { "Level", "Code", "@Month", "@Year" };
            object[] myValues = new object[] { Level, Code, Month, Year };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_RATE_ReportRate2", myParams, myValues);
        }

        public DataTable ReportRate3(int Level, string Code, int Month, int Year)
        {
            string[] myParams = new string[] { "Level", "Code", "@Month", "@Year" };
            object[] myValues = new object[] { Level, Code, Month, Year };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_RATE_ReportRate3", myParams, myValues);
        }

        public DataTable ReportRate4(int Level, string Code, int Quarter, int Year)
        {
            string[] myParams = new string[] { "Level", "Code", "@Quarter", "@Year" };
            object[] myValues = new object[] { Level, Code, Quarter, Year };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_RATE_ReportRate4", myParams, myValues);
        }

        public DataTable ReportRate5(int Level, string Code, int Year)
        {
            string[] myParams = new string[] { "Level", "Code", "@Year" };
            object[] myValues = new object[] { Level, Code, Year };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_RATE_ReportRate5", myParams, myValues);
        }

        public DataTable TotalUpRate(int Level, string Code, int FromMonth, int ToMonth, int Year, string RateA, string RateB, string RateC)
        {
            string[] myParams = new string[] { "Level", "Code", "@FromMonth", "@ToMonth", "@Year", "@RateA", "@RateB", "@RateC" };
            object[] myValues = new object[] { Level, Code, FromMonth, ToMonth, Year, RateA, RateB, RateC };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_RATE_TotalUpRate", myParams, myValues);
        }

        public string Update()
        {
            string[] myParams = new string[] { "@RateID", "@EmployeeCode", "@Date", "@Violation", "@IsRecidivism", "@IsDiscipline", "@Minus", "@MyPlus", "@MyRate", "@OwnerPlus", "@OwnerRate", "@Description" };
            object[] myValues = new object[] { this.m_RateID, this.m_EmployeeCode, this.m_Date, this.m_Violation, this.m_IsRecidivism, this.m_IsDiscipline, this.m_Minus, this.m_MyPlus, this.m_MyRate, this.m_OwnerPlus, this.m_OwnerRate, this.m_Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_RATE_Update", myParams, myValues);
        }

        public string Update(Guid RateID, string EmployeeCode, DateTime Date, string Violation, bool IsRecidivism, bool IsDiscipline, double Minus, double MyPlus, string MyRate, double OwnerPlus, string OwnerRate, string Description)
        {
            string[] myParams = new string[] { "@RateID", "@EmployeeCode", "@Date", "@Violation", "@IsRecidivism", "@IsDiscipline", "@Minus", "@MyPlus", "@MyRate", "@OwnerPlus", "@OwnerRate", "@Description" };
            object[] myValues = new object[] { RateID, EmployeeCode, Date, Violation, IsRecidivism, IsDiscipline, Minus, MyPlus, MyRate, OwnerPlus, OwnerRate, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_RATE_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, Guid RateID, string EmployeeCode, DateTime Date, string Violation, bool IsRecidivism, bool IsDiscipline, double Minus, double MyPlus, string MyRate, double OwnerPlus, string OwnerRate, string Description)
        {
            string[] myParams = new string[] { "@RateID", "@EmployeeCode", "@Date", "@Violation", "@IsRecidivism", "@IsDiscipline", "@Minus", "@MyPlus", "@MyRate", "@OwnerPlus", "@OwnerRate", "@Description" };
            object[] myValues = new object[] { RateID, EmployeeCode, Date, Violation, IsRecidivism, IsDiscipline, Minus, MyPlus, MyRate, OwnerPlus, OwnerRate, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_RATE_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, Guid RateID, string EmployeeCode, DateTime Date, string Violation, bool IsRecidivism, bool IsDiscipline, double Minus, double MyPlus, string MyRate, double OwnerPlus, string OwnerRate, string Description)
        {
            string[] myParams = new string[] { "@RateID", "@EmployeeCode", "@Date", "@Violation", "@IsRecidivism", "@IsDiscipline", "@Minus", "@MyPlus", "@MyRate", "@OwnerPlus", "@OwnerRate", "@Description" };
            object[] myValues = new object[] { RateID, EmployeeCode, Date, Violation, IsRecidivism, IsDiscipline, Minus, MyPlus, MyRate, OwnerPlus, OwnerRate, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_RATE_Update", myParams, myValues);
        }

        [DisplayName("Date"), Category("Column")]
        public DateTime Date
        {
            get
            {
                return this.m_Date;
            }
            set
            {
                this.m_Date = value;
            }
        }

        [Category("Column"), DisplayName("Description")]
        public string Description
        {
            get
            {
                return this.m_Description;
            }
            set
            {
                this.m_Description = value;
            }
        }

        [DisplayName("EmployeeCode"), Category("Column")]
        public string EmployeeCode
        {
            get
            {
                return this.m_EmployeeCode;
            }
            set
            {
                this.m_EmployeeCode = value;
            }
        }

        [Category("Column"), DisplayName("IsDiscipline")]
        public bool IsDiscipline
        {
            get
            {
                return this.m_IsDiscipline;
            }
            set
            {
                this.m_IsDiscipline = value;
            }
        }

        [DisplayName("IsRecidivism"), Category("Column")]
        public bool IsRecidivism
        {
            get
            {
                return this.m_IsRecidivism;
            }
            set
            {
                this.m_IsRecidivism = value;
            }
        }

        [Category("Column"), DisplayName("Minus")]
        public double Minus
        {
            get
            {
                return this.m_Minus;
            }
            set
            {
                this.m_Minus = value;
            }
        }

        [DisplayName("MyPlus"), Category("Column")]
        public double MyPlus
        {
            get
            {
                return this.m_MyPlus;
            }
            set
            {
                this.m_MyPlus = value;
            }
        }

        [Category("Column"), DisplayName("MyRate")]
        public string MyRate
        {
            get
            {
                return this.m_MyRate;
            }
            set
            {
                this.m_MyRate = value;
            }
        }

        [DisplayName("OwnerPlus"), Category("Column")]
        public double OwnerPlus
        {
            get
            {
                return this.m_OwnerPlus;
            }
            set
            {
                this.m_OwnerPlus = value;
            }
        }

        [DisplayName("OwnerRate"), Category("Column")]
        public string OwnerRate
        {
            get
            {
                return this.m_OwnerRate;
            }
            set
            {
                this.m_OwnerRate = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class HRM_PROCESS_RATE";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        [DisplayName("RateID"), Category("Primary Key")]
        public Guid RateID
        {
            get
            {
                return this.m_RateID;
            }
            set
            {
                this.m_RateID = value;
            }
        }

        [Category("Column"), DisplayName("Violation")]
        public string Violation
        {
            get
            {
                return this.m_Violation;
            }
            set
            {
                this.m_Violation = value;
            }
        }
    }
}

